package com.gcl.singleton;

public class Singleton5 {
	
	//私有构造方法，防止被实例化
	private Singleton5(){
	}

	private static class SingletonFactory{
		private static Singleton5 instance = new Singleton5();
	}
	
	//静态工程方法，创建实例
	public static Singleton5 getInstance() {
		
		return SingletonFactory.instance;
	}
	
	//如果该对象被用于序列化，可以保证对象在序列化前后保持一致
	public Object readResolve(){
		return getInstance();
	}
	
}
